package leetcode.每日一题;

import org.junit.Test;

/**
 * @author :songyaozhang
 * @date :Created 2021/8/9 9:54
 * @description :https://leetcode-cn.com/problems/ugly-number/
 */
public class 丑数 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.isUgly(12));
    }

    class Solution {
        public boolean isUgly(int n) {
            if (n <= 0) return false;
            int[] factors = {2, 3, 5};
            for (int factor : factors) {
                while (n % factor == 0) {
                    n /= factor;
                }
            }
            return n == 1;
        }
    }


}
